/*
* @Date: 2021/3/28
* @Author: XueChengwu <xuechengwu@erayt.com>
* @Copyright: 2015-2019 Erayt, Inc.
* @Description: If you have some questions, please contact: xuechengwu@erayt.com.
*/
import controller from '../core/controller'
import { get, post } from '../core/route';
import { db, tran, id } from '../core/db/mysql/db';
import Query from '../core/db/mysql/query';
import { check_captcha, no_repeat } from '../behaviour/common';
import { login } from '../decorater/auth';
import Validator from '../core/validator'
import UserValidator from '../validator/buUser';
import i18n from '../core/i18n';
import utils from '../core/utils';

@controller()
export default class user{
  @login
  @get('front/project')
  async workbench() {
    let page = await this.fetch('front/project');
    return page;
  }

  @login
  @get('api/projectDetail')
  async getProjectDetail() {
    const { shortcode } = this.params;
    try {
      await db(async conn => {
        const projectQuery = new Query(conn, 'bu_project');
        const projectDetail = await projectQuery.where('shortcode', shortcode).find();
        this.assign('detail', projectDetail);
      });
      return this.setCode(0).setMsg('获取成功').json();
    } catch(err) {
      console.log('err====>', err);
      return this.setCode(1).setMsg('获取失败').json();
    }
  }
}
